package com.ruoyi.project.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.BankUtil;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.system.mapper.SysBankMapper;
import com.ruoyi.project.system.domain.SysBank;
import com.ruoyi.project.system.service.ISysBankService;

/**
 * 银行卡Service业务层处理
 * 
 * @author jjp
 * @date 2020-04-17
 */
@Service
public class SysBankServiceImpl implements ISysBankService 
{
    @Autowired
    private SysBankMapper sysBankMapper;

    /**
     * 查询银行卡
     * 
     * @param userId 用户ID
     * @return 银行卡
     */
    @Override
    public SysBank selectSysBankById(Long userId)
    {
        return sysBankMapper.selectSysBankById(userId);
    }

    /**
     * 查询银行卡列表
     * 
     * @param sysBank 银行卡
     * @return 银行卡
     */
    @Override
    public List<SysBank> selectSysBankList(SysBank sysBank)
    {
        return sysBankMapper.selectSysBankList(sysBank);
    }

    /**
     * 新增银行卡
     * 
     * @param sysBank 银行卡
     * @return 结果
     */
    @Override
    public int insertSysBank(SysBank sysBank)
    {
        sysBank.setCreateTime(DateUtils.getNowDate());
        String bankCard = sysBank.getBankCard();
        sysBank.setBankType(BankUtil.GetbankName(bankCard));
        return sysBankMapper.insertSysBank(sysBank);
    }

    /**
     * 修改银行卡
     * 
     * @param sysBank 银行卡
     * @return 结果
     */
    @Override
    public int updateSysBank(SysBank sysBank)
    {
        return sysBankMapper.updateSysBank(sysBank);
    }

    /**
     * 批量删除银行卡
     * 
     * @param bankIds 需要删除的银行卡ID
     * @return 结果
     */
    @Override
    public int deleteSysBankByIds(Long[] bankIds)
    {
        return sysBankMapper.deleteSysBankByIds(bankIds);
    }

    /**
     * 删除银行卡信息
     * 
     * @param bankId 银行卡ID
     * @return 结果
     */
    @Override
    public int deleteSysBankById(Long bankId)
    {
        return sysBankMapper.deleteSysBankById(bankId);
    }

}
